<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Client extends CI_Controller {

	function __construct() {
		parent::__construct();
		$this -> load -> model('m_infus');
		$this->load->helper('url');
		$server_url = "http://localhost/infusalarm-server/index.php/server";
                
		$this->load->library('xmlrpc');
		$this->xmlrpc->server($server_url, 80);
		
                //$this->xmlrpc->set_debug(TRUE);
		
	}

	public function index()
	{
		$this->xmlrpc->method('tes');
		$request = array('<h1><a href="#">WELCOME TO WEBSERVICE</a></h1>');
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
	
			echo $this->xmlrpc->display_response();
		
		}
	}
	public function infus()
	{
		$this->xmlrpc->method('infus');
		$request = array(6);
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	
        public function pasien()
	{
		$this->xmlrpc->method('pasien');
		$request = array(0);
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
        
	public function cekbyidinfus()
	{
		$this->xmlrpc->method('cekbyidinfus');
		$request = array(3);
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
        public function ubahalarm()
	{
		$this->xmlrpc->method('ubahalarm');
		$request = array("2014-01-20 06:45:24","2");
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	public function login()
	{
		$this->xmlrpc->method('login');
		$request = array('asukasukagw','alakazam');
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	
	public function pasienbyid()
	{
		$this->xmlrpc->method('pasienbyid');
		$request = array('1');
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	
	public function tambahinfus()
	{
		$this->xmlrpc->method('tambahinfus');
		$request = array('1','1','2014-01-11 07:20:20','2','250','12','1789','2014-01-11 07:20:20','ini catatan','2014-01-11 07:20:20');
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	
	public function tambahcek() {
		$this->xmlrpc->method('tambahcek');
		$request = array('3','200','matio lee');
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	
	public function ubahInfus() {
	}
	
	public function ubahCek() {
	}
	
	public function deleteInfus() {
		$this->xmlrpc->method('deleteInfus');
		$request = array('2');
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	
	public function deleteCek() {
		$this->xmlrpc->method('deleteCek');
		$request = array('2');
		$this->xmlrpc->request($request);

		if ( ! $this->xmlrpc->send_request())
		{
			echo $this->xmlrpc->display_error();
		}
		else
		{
			echo '<pre>';
			print_r($this->xmlrpc->display_response());
			echo '</pre>';
		}
	}
	
}
